package com.shq.ex1.bus.activity;

import java.util.ArrayList;
import java.util.List;

import com.shq.ex1.bus.util.UtilMethod;
import com.shq.ex1.R;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class ZhanByXianActivity01 extends Activity {
	private ListView zhanByXian01 = null;
	private List<String> zhanByXianResult = null;
	private ArrayAdapter<String> adapter = null;
	private String xianlu = null;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.zhanbyxian1);
		zhanByXian01 = (ListView) findViewById(R.id.zhanByXian01);
		zhanByXianResult = new ArrayList<String>();
		Intent intent = getIntent();
		final String databasePath = intent.getStringExtra("databasePath");
		xianlu = intent.getStringExtra("xianlu");
		zhanByXianResult = UtilMethod.getZhanByXianBack(databasePath, xianlu);	
		adapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,zhanByXianResult);
		zhanByXian01.setAdapter(adapter);
		zhanByXian01.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				Intent intent = new Intent();
				intent.putExtra("databasePath", databasePath);
				intent.putExtra("zhandian", arg0.getItemAtPosition(arg2).toString().substring(String.valueOf(arg2).length()));
				intent.setClass(ZhanByXianActivity01.this, ZhanResultActivity.class);
				ZhanByXianActivity01.this.startActivity(intent);				
			}
		});
		
	}

}
